package poo.eratostene;

import java.util.Iterator;

public abstract class CrivelloAstratto implements Crivello {

	public int size() {
		int c = 0;
		for (@SuppressWarnings("unused")
		int x : this)
			c++;
		return c;
	}

	public String toString() {

		StringBuilder sb = new StringBuilder(500);
		int c = 0;
		Iterator<Integer> it = this.iterator();
		while (it.hasNext()) {
			sb.append(String.format("%11d", it.next()));
			c++;
			if (c % 7 == 0) {
				sb.append("\n");
			}
		}
		return sb.toString();
	}

	public int hashCode() {
		int h = 0;
		h = this.hashCode() * 13;
		h = h + h * 13;
		return h;
	}

	public boolean equals(Object x) {
		if (!(x instanceof CrivelloAstratto))
			return false;
		CrivelloAstratto a = (CrivelloAstratto) x;
		if (this.equals(a))
			return true;
		return false;

	}
}
